const http=require('http')
const fs=require('fs')
var list=[];
var bur=false;
http.createServer((req,res)=>{
    var str='';
    req.on('data',(chunk)=>{
        str+=chunk
    })
    req.on('end',()=>{
        var obj=JSON.parse(str);
        console.log(obj.userName,obj.pwd);
        var json=fs.readFileSync('./userList.json').toString();
        json=JSON.parse(json);
        // console.log(json)
        for(var i=0,l=json.length;i<l;i++){
            list.push({userName:json[i].userName,pwd:json[i].pwd}) 
        }
        console.log(list)
        for(var m=0;m<list.length;m++){
            if(list[m].userName==obj.userName&&list[m].pwd==obj.pwd){
               bur=true;
            }
        }
        if(bur==true){
            console.log('登陆成功')
        }else{
            console.log('用户名，密码不正确')
        }
        
    })
}).listen(8081)